{"ast":null,"code":"import _objectSpread from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/objectSpread2.js\";import _toConsumableArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js\";import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from\"react\";import{DialogInput as DialogInputComponent}from\"../components\";import{Context}from\"../index\";import{observer}from\"mobx-react-lite\";import mime from\"mime\";import{jsx as _jsx}from\"react/jsx-runtime\";var DialogInput=function DialogInput(_ref){var chat=_ref.chat;window.navigator.getUserMedia=window.navigator.getUserMedia||window.navigator.mozGetUserMedia||window.navigator.msGetUserMedia||window.navigator.webkitGetUserMedia;var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),value=_React$useState2[0],setValue=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),emojiPickerVisible=_React$useState4[0],setEmojiPickerVisible=_React$useState4[1];var _React$useState5=React.useState(false),_React$useState6=_slicedToArray(_React$useState5,2),flagForStyle=_React$useState6[0],setFlagForStyle=_React$useState6[1];var _React$useState7=React.useState(false),_React$useState8=_slicedToArray(_React$useState7,2),isRecording=_React$useState8[0],setIsRecording=_React$useState8[1];var _React$useState9=React.useState(false),_React$useState10=_slicedToArray(_React$useState9,2),isShortInput=_React$useState10[0],setIsShortInput=_React$useState10[1];var _React$useState11=React.useState(0),_React$useState12=_slicedToArray(_React$useState11,2),cursorPosition=_React$useState12[0],setCursorPosition=_React$useState12[1];var _React$useState13=React.useState(''),_React$useState14=_slicedToArray(_React$useState13,2),textField=_React$useState14[0],setTextField=_React$useState14[1];var _React$useState15=React.useState(null),_React$useState16=_slicedToArray(_React$useState15,2),mediaRecorder=_React$useState16[0],setMediaRecorder=_React$useState16[1];var _React$useState17=React.useState(),_React$useState18=_slicedToArray(_React$useState17,2),uploaded=_React$useState18[0],setUploaded=_React$useState18[1];var _React$useState19=React.useState(),_React$useState20=_slicedToArray(_React$useState19,2),images=_React$useState20[0],setImages=_React$useState20[1];var _React$useState21=React.useState(),_React$useState22=_slicedToArray(_React$useState21,2),voice=_React$useState22[0],setVoice=_React$useState22[1];var pickerRef=React.useRef(null);var textAreaRef=React.useRef(null);var maxSizeMessage=500;React.useEffect(function(){var _textAreaRef$current;var dialogListInput={items:store.getDialogInput().items?_toConsumableArray(store.getDialogInput().items):[]};(_textAreaRef$current=textAreaRef.current)===null||_textAreaRef$current===void 0?void 0:_textAreaRef$current.focus();if(textField.length>maxSizeMessage*0.05){setFlagForStyle(true);}else{setFlagForStyle(false);}dialogListInput.items[chat.id]={inputText:textField};store.setDialogInput(_objectSpread(_objectSpread({},store.getDialogInput()),dialogListInput));},[textField]);React.useEffect(function(){var _uploaded$items;if(textField.length>0||(uploaded===null||uploaded===void 0?void 0:(_uploaded$items=uploaded.items)===null||_uploaded$items===void 0?void 0:_uploaded$items.length)>0){setValue(true);}else{setValue(false);}},[textField,uploaded]);React.useEffect(function(){if(emojiPickerVisible){var handleClick=function handleClick(e){var _pickerRef$current;if(!pickerRef.current)return;if(!((_pickerRef$current=pickerRef.current)!==null&&_pickerRef$current!==void 0&&_pickerRef$current.contains(e.target))){var _textAreaRef$current2;(_textAreaRef$current2=textAreaRef.current)===null||_textAreaRef$current2===void 0?void 0:_textAreaRef$current2.focus();setEmojiPickerVisible(false);}};document.addEventListener('click',handleClick);return function(){document.removeEventListener('click',handleClick);};}},[emojiPickerVisible]);React.useEffect(function(){var _textAreaRef$current3;if((_textAreaRef$current3=textAreaRef.current)!==null&&_textAreaRef$current3!==void 0&&_textAreaRef$current3.selectionEnd){textAreaRef.current.selectionEnd=cursorPosition;}},[cursorPosition]);React.useEffect(function(){if(store.getDialogInput().items&&store.getDialogInput().items[chat.id]){setTextField(_toConsumableArray(store.getDialogInput().items)[chat.id].inputText);}else{setTextField('');}setCursorPosition(0);setIsShortInput(false);},[chat]);React.useEffect(function(){var _tempUploaded$items;setUploaded({items:[]});var tempUploaded=_objectSpread({},store.getUploadedContentForChats());if((tempUploaded===null||tempUploaded===void 0?void 0:(_tempUploaded$items=tempUploaded.items)===null||_tempUploaded$items===void 0?void 0:_tempUploaded$items.length)>0&&tempUploaded.items[chat.id]){setUploaded({items:tempUploaded.items[chat.id].uploadedContent.items});}},[chat,store.uploadedContentForChats]);React.useEffect(function(){var _uploaded$items2;var tempImagesList={items:[]};setVoice({});if(uploaded!==null&&uploaded!==void 0&&(_uploaded$items2=uploaded.items)!==null&&_uploaded$items2!==void 0&&_uploaded$items2.length){uploaded.items.forEach(function(item,index){var _mime$getType,_mime$getType2;if((_mime$getType=mime.getType(item.link))!==null&&_mime$getType!==void 0&&_mime$getType.includes('image')){tempImagesList.items[index]=item;}else if((_mime$getType2=mime.getType(item.link))!==null&&_mime$getType2!==void 0&&_mime$getType2.includes('webm')){setVoice(item);setIsShortInput(true);}});}setImages(_objectSpread(_objectSpread({},images),tempImagesList));},[uploaded]);var onRecord=function onRecord(){navigator.mediaDevices.getUserMedia({audio:true}).then(function(stream){return onRecording(stream);}).catch(function(err){return onError(err);});};var onRecording=function onRecording(stream){var recorder=new MediaRecorder(stream);setMediaRecorder(recorder);recorder.start();recorder.onstart=function(){setIsRecording(true);setIsShortInput(true);};recorder.onstop=function(){setIsRecording(false);};recorder.ondataavailable=function(e){var file=new File([e.data],'audio.webm');store.uploadFiles([file]);};};var onStopRecording=function onStopRecording(){setIsRecording(false);mediaRecorder===null||mediaRecorder===void 0?void 0:mediaRecorder.stop();};var onError=function onError(err){console.log('The following error occured: '+err);};var toggleEmojiPicker=function toggleEmojiPicker(){var _textAreaRef$current4;(_textAreaRef$current4=textAreaRef.current)===null||_textAreaRef$current4===void 0?void 0:_textAreaRef$current4.focus();setEmojiPickerVisible(!emojiPickerVisible);};var addEmoji=function addEmoji(identifier){var ref=textAreaRef.current;ref===null||ref===void 0?void 0:ref.focus();var start=textField.substring(0,ref===null||ref===void 0?void 0:ref.selectionStart)||'';var end=textField.substring((ref===null||ref===void 0?void 0:ref.selectionStart)||500)||'';setTextField(start+identifier+end);setCursorPosition(start.length+identifier.length);};var uploadDocumentHandler=React.useCallback(function(e){var collectionFiles=[];if(e.target.files){_toConsumableArray(e.target.files).forEach(function(item){var file=item;collectionFiles.push(file);});store.uploadFiles(collectionFiles);}e.target.value='';},[store]);var handleSendMessage=function handleSendMessage(){// TODO: пересылка сообщений\nif(textField.trim().length>0||images!==null&&images!==void 0&&images.items.length||voice!==null&&voice!==void 0&&voice.id){var messageRequest={};var bodyMessage={};var contentListResponse={items:[]};var replyMessage={items:[]};var tempUploadedContent=_objectSpread({},store.getUploadedContentForChats());if(textField.trim().length>0||textField.length-1<=maxSizeMessage){bodyMessage.message=textField.trim();}if(images!==null&&images!==void 0&&images.items.length){contentListResponse=_objectSpread({},images);}if(voice!==null&&voice!==void 0&&voice.id){// @ts-ignore\ncontentListResponse.items.push(_objectSpread({},voice));}bodyMessage.content=contentListResponse;bodyMessage.replyMessage=replyMessage;messageRequest.chat=chat.id.toString();messageRequest.bodyMessage=bodyMessage;if((images!==null&&images!==void 0&&images.items.length||voice!==null&&voice!==void 0&&voice.id)&&tempUploadedContent.items[chat.id]){tempUploadedContent.items[chat.id].uploadedContent.items.splice(0);store.setUploadedContentForChats(_objectSpread(_objectSpread({},store.getUploadedContentForChats()),tempUploadedContent));}store.addMessageAPI(messageRequest).then(function(){setTextField('');setIsShortInput(false);});}setEmojiPickerVisible(false);};var handleDeleteContent=function handleDeleteContent(contentId){store.deleteUploadedContent(chat.id,contentId);setIsShortInput(false);};return/*#__PURE__*/_jsx(DialogInputComponent,{toggleEmojiPicker:toggleEmojiPicker,emojiPickerVisible:emojiPickerVisible,setEmojiPickerVisible:setEmojiPickerVisible,value:value,textField:textField,setTextField:setTextField,maxSizeMessage:maxSizeMessage,uploadDocumentHandler:uploadDocumentHandler,handleSendMessage:handleSendMessage,pickerRef:pickerRef,addEmoji:addEmoji,flagForStyle:flagForStyle,textAreaRef:textAreaRef,images:images||{items:[]},voice:voice,callbackOnDeleteContent:handleDeleteContent,onRecord:onRecord,onStopRecording:onStopRecording,isRecording:isRecording,isShortInput:isShortInput});};export default observer(DialogInput);","map":{"version":3,"names":["React","DialogInput","DialogInputComponent","Context","observer","mime","chat","window","navigator","getUserMedia","mozGetUserMedia","msGetUserMedia","webkitGetUserMedia","useContext","store","useState","value","setValue","emojiPickerVisible","setEmojiPickerVisible","flagForStyle","setFlagForStyle","isRecording","setIsRecording","isShortInput","setIsShortInput","cursorPosition","setCursorPosition","textField","setTextField","mediaRecorder","setMediaRecorder","uploaded","setUploaded","images","setImages","voice","setVoice","pickerRef","useRef","textAreaRef","maxSizeMessage","useEffect","dialogListInput","items","getDialogInput","current","focus","length","id","inputText","setDialogInput","handleClick","e","contains","target","document","addEventListener","removeEventListener","selectionEnd","tempUploaded","getUploadedContentForChats","uploadedContent","uploadedContentForChats","tempImagesList","forEach","item","index","getType","link","includes","onRecord","mediaDevices","audio","then","stream","onRecording","catch","err","onError","recorder","MediaRecorder","start","onstart","onstop","ondataavailable","file","File","data","uploadFiles","onStopRecording","stop","console","log","toggleEmojiPicker","addEmoji","identifier","ref","substring","selectionStart","end","uploadDocumentHandler","useCallback","collectionFiles","files","push","handleSendMessage","trim","messageRequest","bodyMessage","contentListResponse","replyMessage","tempUploadedContent","message","content","toString","splice","setUploadedContentForChats","addMessageAPI","handleDeleteContent","contentId","deleteUploadedContent"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/containers/DialogInput.tsx"],"sourcesContent":["import React from \"react\";\nimport {DialogInputContainerProps} from \"../models/props/DialogInputContainerProps\";\nimport {ContentListResponse} from \"../models/response/ContentListResponse\";\nimport {ContentListItem} from \"../models/response/ContentListItem\";\nimport {ShortChatList} from \"../models/uploadedStoreModel/ShortChatList\";\nimport {InputTextList} from \"../models/inputDialogModel/InputTextList\";\nimport {DialogInput as DialogInputComponent} from \"../components\";\nimport {Context} from \"../index\";\nimport {observer} from \"mobx-react-lite\";\nimport mime from \"mime\";\nimport MessageRequest from \"../models/request/MessageRequest\";\nimport {MessageItem} from \"../models/response/MessageItem\";\nimport {MessagesShortListResponse} from \"../models/response/MessagesShortListResponse\";\n\nconst DialogInput: React.FC<DialogInputContainerProps> = ({chat}) => {\n\n    window.navigator.getUserMedia =\n        window.navigator.getUserMedia ||\n        window.navigator.mozGetUserMedia ||\n        window.navigator.msGetUserMedia ||\n        window.navigator.webkitGetUserMedia;\n\n    const {store} = React.useContext(Context);\n\n    const [value, setValue] = React.useState<boolean>(false);\n    const [emojiPickerVisible, setEmojiPickerVisible] = React.useState<boolean>(false);\n    const [flagForStyle, setFlagForStyle] = React.useState<boolean>(false);\n    const [isRecording, setIsRecording] = React.useState<boolean>(false);\n    const [isShortInput, setIsShortInput] = React.useState<boolean>(false);\n\n    const [cursorPosition, setCursorPosition] = React.useState<number>(0);\n    const [textField, setTextField] = React.useState<string>('');\n\n    const [mediaRecorder, setMediaRecorder] = React.useState<MediaRecorder | null>(null);\n\n    const [uploaded, setUploaded] = React.useState<ContentListResponse>();\n    const [images, setImages] = React.useState<ContentListResponse>();\n    const [voice, setVoice] = React.useState<ContentListItem>();\n\n    const pickerRef = React.useRef<null | HTMLDivElement>(null);\n    const textAreaRef = React.useRef<null | HTMLTextAreaElement>(null);\n\n    const maxSizeMessage: number = 500;\n\n    React.useEffect(() => {\n        let dialogListInput: InputTextList = {\n          items: store.getDialogInput().items?\n              [...store.getDialogInput().items]:\n              []\n        };\n        textAreaRef.current?.focus();\n\n        if (textField.length > maxSizeMessage * 0.05) {\n            setFlagForStyle(true);\n        } else {\n            setFlagForStyle(false);\n        }\n\n        dialogListInput.items[chat.id] = {\n            inputText: textField\n        };\n\n        store.setDialogInput({\n            ...store.getDialogInput(),\n            ...dialogListInput\n        });\n    }, [textField]);\n\n    React.useEffect(() => {\n        if (textField.length > 0 || uploaded?.items?.length! > 0) {\n            setValue(true);\n        } else {\n            setValue(false);\n        }\n    }, [textField, uploaded]);\n\n    React.useEffect(() => {\n        if (emojiPickerVisible) {\n            const handleClick = (e: any) => {\n                if (!pickerRef.current) return;\n                if (!pickerRef.current?.contains(e.target)) {\n                    textAreaRef.current?.focus();\n                    setEmojiPickerVisible(false);\n                }\n            }\n\n            document.addEventListener('click', handleClick);\n\n            return () => {\n                document.removeEventListener('click', handleClick)\n            }\n        }\n    }, [emojiPickerVisible]);\n\n    React.useEffect(() => {\n        if (textAreaRef.current?.selectionEnd!) {\n            textAreaRef.current.selectionEnd = cursorPosition;\n        }\n    }, [cursorPosition]);\n\n    React.useEffect(() => {\n        if (store.getDialogInput().items && store.getDialogInput().items[chat.id]) {\n            setTextField([...store.getDialogInput().items][chat.id].inputText);\n        } else {\n            setTextField('');\n        }\n        setCursorPosition(0);\n        setIsShortInput(false);\n    }, [chat]);\n\n    React.useEffect(() => {\n        setUploaded({items: []});\n        const tempUploaded: ShortChatList = {...store.getUploadedContentForChats()};\n\n        if (tempUploaded?.items?.length > 0 &&\n            tempUploaded.items[chat.id]\n        ) {\n            setUploaded({\n                items: tempUploaded.items[chat.id].uploadedContent.items\n            });\n        }\n    }, [chat, store.uploadedContentForChats]);\n\n    React.useEffect(() => {\n        let tempImagesList: ContentListResponse = {items: []};\n        setVoice({} as ContentListItem);\n\n        if (uploaded?.items?.length) {\n            uploaded.items.forEach((item, index) => {\n                if (mime.getType(item.link)?.includes('image')) {\n                    tempImagesList.items[index] = item;\n                } else if (mime.getType(item.link)?.includes('webm')) {\n                    setVoice(item);\n                    setIsShortInput(true);\n                }\n            });\n        }\n\n        setImages({\n            ...images,\n            ...tempImagesList\n        });\n    }, [uploaded]);\n\n    const onRecord = () => {\n        navigator.mediaDevices.getUserMedia({audio: true}).\n        then(stream => onRecording(stream)).\n        catch(err => onError(err));\n    };\n\n    const onRecording = (stream: MediaStream) => {\n        const recorder = new MediaRecorder(stream);\n        setMediaRecorder(recorder);\n\n        recorder.start();\n\n        recorder.onstart = () => {\n            setIsRecording(true);\n            setIsShortInput(true);\n        };\n\n        recorder.onstop = () => {\n            setIsRecording(false);\n        };\n\n        recorder.ondataavailable = e => {\n            const file = new File([e.data], 'audio.webm');\n            store.uploadFiles([file]);\n        };\n    };\n\n    const onStopRecording = () => {\n        setIsRecording(false);\n        mediaRecorder?.stop();\n    }\n\n    const onError = (err: MediaStreamError) => {\n        console.log('The following error occured: ' + err);\n    };\n\n    const toggleEmojiPicker = () => {\n        textAreaRef.current?.focus();\n        setEmojiPickerVisible(!emojiPickerVisible);\n    }\n\n    const addEmoji = (identifier: string) => {\n        const ref = textAreaRef.current;\n        ref?.focus();\n\n        const start: string = textField.substring(0, ref?.selectionStart) || '';\n        const end: string = textField.substring(ref?.selectionStart || 500) || '';\n\n        setTextField(start + identifier + end);\n        setCursorPosition(start.length + identifier.length);\n    }\n\n    const uploadDocumentHandler = React.useCallback( (e: React.ChangeEvent<HTMLInputElement>) => {\n        let collectionFiles: File[] = [];\n        if (e.target.files) {\n            [...e.target.files].forEach((item) => {\n                const file: File = item;\n                collectionFiles.push(file);\n            });\n            store.uploadFiles(collectionFiles);\n        }\n        e.target.value = '';\n    }, [store]);\n\n    const handleSendMessage = () => {\n        // TODO: пересылка сообщений\n        if (textField.trim().length > 0 || images?.items.length || voice?.id) {\n            let messageRequest = {} as MessageRequest;\n            let bodyMessage = {} as MessageItem;\n            let contentListResponse = {items: []} as ContentListResponse;\n            let replyMessage = {items: []} as MessagesShortListResponse;\n\n            let tempUploadedContent = {...store.getUploadedContentForChats()} as ShortChatList;\n\n            if (textField.trim().length > 0 || textField.length - 1 <= maxSizeMessage) {\n                bodyMessage.message = textField.trim();\n            }\n\n            if (images?.items.length) {\n                contentListResponse = {...images};\n            }\n\n            if (voice?.id) {\n                // @ts-ignore\n                contentListResponse.items.push({...voice});\n            }\n\n            bodyMessage.content = contentListResponse;\n            bodyMessage.replyMessage = replyMessage;\n\n            messageRequest.chat = chat.id.toString();\n            messageRequest.bodyMessage = bodyMessage;\n\n            if ((images?.items.length || voice?.id) && tempUploadedContent.items[chat.id]) {\n                tempUploadedContent.items[chat.id].uploadedContent.items.splice(0);\n\n                store.setUploadedContentForChats({\n                    ...store.getUploadedContentForChats(),\n                    ...tempUploadedContent\n                });\n            }\n\n            store.addMessageAPI(messageRequest).then(() => {\n                setTextField('');\n                setIsShortInput(false);\n            });\n        }\n\n        setEmojiPickerVisible(false);\n    }\n\n    const handleDeleteContent = (contentId: string) => {\n        store.deleteUploadedContent(chat.id, contentId);\n        setIsShortInput(false);\n    }\n\n    return (\n        <DialogInputComponent\n            toggleEmojiPicker={toggleEmojiPicker}\n            emojiPickerVisible={emojiPickerVisible}\n            setEmojiPickerVisible={setEmojiPickerVisible}\n            value={value}\n            textField={textField}\n            setTextField={setTextField}\n            maxSizeMessage={maxSizeMessage}\n            uploadDocumentHandler={uploadDocumentHandler}\n            handleSendMessage={handleSendMessage}\n            pickerRef={pickerRef}\n            addEmoji={addEmoji}\n            flagForStyle={flagForStyle}\n            textAreaRef={textAreaRef}\n            images={images || {items: []}}\n            voice={voice}\n            callbackOnDeleteContent={handleDeleteContent}\n            onRecord={onRecord}\n            onStopRecording={onStopRecording}\n            isRecording={isRecording}\n            isShortInput={isShortInput}\n        />\n    );\n}\n\nexport default observer(DialogInput);"],"mappings":"ibAAA,MAAOA,MAAK,KAAM,OAAO,CAMzB,OAAQC,WAAW,GAAIC,qBAAoB,KAAO,eAAe,CACjE,OAAQC,OAAO,KAAO,UAAU,CAChC,OAAQC,QAAQ,KAAO,iBAAiB,CACxC,MAAOC,KAAI,KAAM,MAAM,CAAC,2CAKxB,GAAMJ,YAAgD,CAAG,QAAnDA,YAAgD,MAAe,IAAVK,KAAI,MAAJA,IAAI,CAE3DC,MAAM,CAACC,SAAS,CAACC,YAAY,CACzBF,MAAM,CAACC,SAAS,CAACC,YAAY,EAC7BF,MAAM,CAACC,SAAS,CAACE,eAAe,EAChCH,MAAM,CAACC,SAAS,C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